package edu.fim.data.dao;

import java.util.ResourceBundle;

import javax.persistence.EntityManager;

import edu.fim.presentation.model.bean.Meal;

public class MealDAO extends AbstractDAO<Meal, Integer> {

	private static ResourceBundle bundle = ResourceBundle.getBundle("META-INF/properties/MealSQL");

	public MealDAO(EntityManager entityManager) {
		super(entityManager, Meal.class);
	}

	public void persist(Meal entity) {
		String sql = bundle.getString("findLast");
		Meal lastEntity = findEntitiesByQuery(sql).get(0);
		entity.setId(lastEntity.getId() + 1);
		entityManager.persist(entity);
	}
}